import com.itgao.mapper.CustomerMapper;
import com.itgao.mapper.StudentMapper;
import com.itgao.mapper.UserMapper;
import com.itgao.Utils.SqlSessionFactoryUtils;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.junit.Test;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class demo1 {
    @Test
    public void selectAll() {
        SqlSession session = SqlSessionFactoryUtils.getSqlSessionFactory();
        UserMapper mapper = session.getMapper(UserMapper.class);
        Map<String, Object> map = new HashMap<>();
        map.put("end", 3);
        map.put("beg", 0);
        System.out.println(mapper.selectlimit(map).toString());
        System.out.println(mapper.selectAll().toString());
    }

    @Test
    public void SelectTeacher() {
        SqlSession session = SqlSessionFactoryUtils.getSqlSessionFactory();
        StudentMapper mapper = session.getMapper(StudentMapper.class);
        System.out.print(mapper.getStudent2());
    }

    @Test
    public void selectIF() {
        SqlSession session = SqlSessionFactoryUtils.getSqlSessionFactory();
       /* HashMap map = new HashMap();
        map.put("id", 1);
        map.put("jobs", "teacher2");
        session.getMapper(CustomerMapper.class).updateIdAndId(map);
        session.commit();*/
        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        System.out.println(session.getMapper(CustomerMapper.class).selectForeach(list));

    }
}